package convertedores;

import entidades.Processo;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import rn.ProcessoRN;

/**
 *
 * @author marcelo
 */
//@FacesConverter(forClass = Processo.class)
public class ConverteStatus implements Converter 
{
    @Override
    public Object getAsObject(FacesContext fc, UIComponent uic, String idrevisao) {
        return (Object)idrevisao;
    }

    @Override
    public String getAsString(FacesContext fc, UIComponent uic, Object o) 
    {
        try 
        {
            Integer id = (Integer)o;
            ProcessoRN processoRN = new ProcessoRN();
            Processo processo = processoRN.carregarProcesso(id);
            if (processo.getStatus() == 1) {
                return "Ativo";
            }
            if (processo.getStatus() == 2) {
                return "Arquivado";
            }
        } 
        catch (Exception ex) {
            Logger.getLogger(ConverteStatus.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
}